<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<?php
$servername = "mysql";
$username = "root";
$password = "password";
$dbname = "test";

// 创建连接
$conn = new mysqli($servername, $username, $password, $dbname);
// 检测连接
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
}

$sql = "SELECT product_id, name FROM product";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // 输出每行数据
    while($row = $result->fetch_assoc()) {
        echo "<br> id: ". $row["product_id"]. " - Name: ". $row["name"];
    }
} else {
    echo "0 个结果";
}
$conn->close();
?>
<ul>
    <li><a href="add_form.html">add_form.html</a></li>
    <li><a href="product.php">product</a></li>
</ul>
</body>
</html>
